package com.jt.system.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jt.system.pojo.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author 金帮嘉诚 @date 2021-08-31 星期二 15:34
 */
@Mapper
public interface UserMapper extends BaseMapper<User> {
    /**
     * 根据用户名 获取用户信息
     *
     * @param username
     * @return
     */
    @Select("select id,username,password,status " +
            "from tb_users " +
            "where username = #{username}")
    User selectUserByUsername(String username);


    @Select("select distinct m.permission " +
            "from " +
            "tb_user_roles ur " +
            "join tb_role_menus rm " +
            "join tb_menus m " +
            "on ur.role_id =rm.role_id " +
            "and rm.menu_id = m.id " +
            "where ur.user_id = #{id} ")
    List<String> selectUserPermissions(Long id);
}
